package com.luhuiguo.cms.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.luhuiguo.cms.client.gin.Injector;
import com.luhuiguo.cms.client.presenter.AppPresenter;
import com.luhuiguo.gwt.presenter.client.place.PlaceManager;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Application implements EntryPoint {

    private final Injector injector = GWT.create(Injector.class);


    public void onModuleLoad() {
        
        Element loading = DOM.getElementById("loading");

        DOM.removeChild(RootPanel.getBodyElement(), loading);
        
        AppResources.INSTANCE.css().ensureInjected();

        Window.setTitle(AppConstants.INSTANCE.appTitle());
        Window.enableScrolling(false);
        Window.setMargin("0px");

        AppPresenter appPresenter = injector.getAppPresenter();
        appPresenter.bind();

        RootLayoutPanel.get().add(appPresenter.getDisplay().asWidget());

        
        
        PlaceManager placeManager = injector.getPlaceManager();
        placeManager.fireCurrentPlace();

    }

}
